<?php
/**
 * Created by PhpStorm.
 * User: extraxue
 * Date: 2018/5/1
 * Time: 下午11:01
 */
error_reporting(E_ALL^E_NOTICE);
?>

<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>
    <title>党支部信息修改</title>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>党支部信息修改</strong></div>
    <div class="body-content">
        <form method="post" class="form-x" action="deptChange.php">
            <div class="form-group" style="margin-top: 30px;">
                <div class="label">
                    <label>查询关键字：</label>
                </div>
                <div class="field">
                    <select class="input" name="searchKind" style="width: 200px" ">
                    <!--                    <option value=" ">请选择...</option>-->
                    <option value="id">党支部ID</option>
                    </select>
                </div>
            </div>
            <?php
            session_start();
            $_SESSION['keyWord']=$keyWord;
            ?>
            <div style="height: 20px"></div>
            <div class="form-group">
                <div class="label">
                    <label>关键字:</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="keyWord" size="50" placeholder="名称支持模糊查询"
                           style="width:200px"/>
                    <div class="field" style="padding-top: 20px;">
                        <button class="button bg-main icon-check-square-o" type="submit">提交</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<?php

require_once('pdo.php');
$searchKind = $_POST['searchKind'];
$keyWord = $_POST['keyWord'];
$_SESSION['keyWord']=$keyWord;

if ($searchKind == 'id') {
    $sqlSearchDeptById = "select * from dept_info a where a.dept_id = '{$keyWord}'";
    $rsSearchDeptById = $pdo->query($sqlSearchDeptById);
    $resultSearchDeptById = $rsSearchDeptById->fetch(PDO::FETCH_ASSOC);
    foreach ($pdo->query($sqlSearchDeptById) as $key => $resultSearchDeptById) {
        ?>

        <div style="height: 20px;"></div>

        <div class="dialog open">
            <div class="dialog-head">
                <h3 style="color: #C50C11">党支部ID：<?php echo "$resultSearchDeptById[dept_id]" ?>
                <a href="deptDeleteCheck.php?uid=<?=$resultSearchDeptById['uid']?>"
                   class="button button-little bg-red" style="padding: 5px 10px;margin-left: 10px;float: right">
                    <span class="icon-power-off" >删除该党支部</span></a></h3>
            </div>

            <form method="get" action="deptChangeCheck.php" id="search_form">

                <div class="dialog-body">
                    <p>
                    <h3><strong>党支部名称：</strong><?php echo "$resultSearchDeptById[dept_name]" ?>
                        <a class="button button-little bg-green" style="padding: 5px 10px;margin-left: 10px;cursor: pointer;" onclick="document.getElementById('newName').style.display='inline'">
                            <span class="">修改</span></a>
                        <div style="display: none;" id="newName">
                            &nbsp;→ &nbsp;
                            <input type="text" class="input" name="newName"
                                   style="width:150px;display: inline;"/>
                            <a class="button button-little bg-yellow" style="padding: 5px 10px;margin-left: 10px;cursor: pointer;" onclick="document:search_form.submit();">
                                <span>提交</span></a>
                        </div>
                    </h3></p>
                    <p><h3><strong>党支部书记姓名：</strong><?php echo "$resultSearchDeptById[dept_leader]" ?>
                        <a  class="button button-little bg-green" style="padding: 5px 10px;margin-left: 10px;cursor: pointer;" onclick="document.getElementById('newLeaderName').style.display='inline'">
                            <span class="">修改</span></a>
                        <div style="display: none;" id="newLeaderName">
                            &nbsp;→ &nbsp;
                            <input type="text" class="input" name="newLeaderName"
                                   style="width:150px;display: inline;"/>
                            <a class="button button-little bg-yellow" style="padding: 5px 10px;margin-left: 10px;cursor: pointer;" onclick="document:search_form.submit();">
                                <span>提交</span></a>
                        </div>
                    </h3></p>
                    <p>
                    <h3><strong>党支部联系电话：</strong><?php echo "$resultSearchDeptById[dept_phone]" ?>
                        <a class="button button-little bg-green" style="padding: 5px 10px;margin-left: 10px;cursor: pointer;" onclick="document.getElementById('newPhone').style.display='inline'">
                            <span class="">修改</span></a>
                        <div style="display: none;" id="newPhone">
                            &nbsp;→ &nbsp;
                            <input type="text" class="input" name="newPhone"
                                   style="width:150px;display: inline;"/>
                            <a class="button button-little bg-yellow" style="padding: 5px 10px;margin-left: 10px;cursor: pointer;" onclick="document:search_form.submit();">
                                <span>提交</span></a>
                        </div>
                    </h3></p>
                </div>
            </form>

        </div>
        <?php
    }?>

    <?php
}
if ($keyWord && !$resultSearchDeptById) {
    ?>
    <p></p>
    <div class="alert alert-red">
        <span class="close"></span><strong>注意：</strong>未查询到次党支部信息</div>

    <?php
}
?>

</body>
</html>
